$(function() {
	$('#entertime').change(function(){
		if('' != $('#leavetime').val()){
			if(Date.parse($('#entertime').val()) > Date.parse($('#leavetime').val())){
				$('#leavetime').val('');
			}
		}
		if('' == $('#entertime').val()){
			$('#leavetime').removeAttr('min');
		} else {
			$('#leavetime').attr('min', $('#entertime').val());
		}
	});
	
	var entertime = $('#entertime').val();
	if(entertime != ''){
		$('#leavetime').attr('min', entertime);
	}
});

function bindShipList(data){
//	var str;
//	if(data.verifyresult == 1)
//		str = '<img src="../../img/jiaoyan1.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="checkInfo('+JSON.stringify(data.verify).replace(/\"/g,"'")+')" title="点击查看详情">'; 
//	else if(data.verifyresult == 0)
//		str = '<img src="../../img/jiaoyan2.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="checkInfo('+JSON.stringify(data.verify).replace(/\"/g,"'")+')" title="点击查看详情">'; 
//	else if(data.verifyresult == -1)
//		str = '<img src="../../img/jiaoyan3.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="checkInfo('+JSON.stringify(data.verify).replace(/\"/g,"'")+')" title="点击查看详情">'; 
//	else   //正在校验中
//		str = '<img src="../../img/loading.gif" alt="" style="width:20px;height:20px;" onclick="" title="数据校验中">';
	var htmlStr = ''+		
				'<tr id="tr_'+ data.shipidnumber +'">'+
				'	<td>'+ data.shipname +'</td>'+
				'	<td>'+ data.shipnameen +'</td>'+
				'	<td>'+ data.imo +'</td>'+
				'	<td>'+ data.portcode +'</td>'+
				'	<td>'+ data.grosstonnage +'</td>'+
				'	<td>'+ data.enginepower +'</td>'+
				'	<td>'+ data.typecode +'</td>'+
				'	<td>'+
				'		<input type="hidden" name="ship" id="ship'+data.shipidnumber+'" value=\''+ JSON.stringify(data) +'\'>'+
				'		<button onclick="deleteShip(\''+data.shipidnumber+'\');" type="button" class="btn btn-danger btn-sm" style="margin-right: 10px;">'+
				'			<span class="glyphicon glyphicon-minus"></span>'+
				'		</button>'+
				'	</td>'+
				'</tr>';

	$('#TableShip').append(htmlStr);
}
function deleteShip(shipidnumber){
	$('#tr_' + shipidnumber).remove();
}

function bindShipInfoList(data){
//	var str = "";
//	if(data.verifyresult >0)
//		str = '<img src="../../img/jiaoyan1.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="getVerify(\''+data.shipidnumber+'\')" title="点击查看详情">'; 
//	else if(data.verifyresult == 0)
//		str = '<img src="../../img/jiaoyan2.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="getVerify(\''+data.shipidnumber+'\')" title="点击查看详情">'; 
//	else if(data.verifyresult == -1)
//		str = '<img src="../../img/jiaoyan3.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="getVerify(\''+data.shipidnumber+'\')" title="点击查看详情">'; 
	
	var htmlStr = ''+		
				'<tr>'+
				'	<td>'+ data.shipname +'</td>'+
				'	<td>'+ data.shipnameen +'</td>'+
				'	<td>'+ data.imo +'</td>'+
				'	<td>'+ data.portcode +'</td>'+
				'	<td>'+ data.grosstonnage +'</td>'+
				'	<td>'+ data.enginepower +'</td>'+
				'	<td>'+ data.typecode +'</td>'+
				'</tr>';
	
	$('#TableShip').append(htmlStr);
}

function bindShipEditList(data){
//	var str;
//	if(data.verifyresult >0)
//		str = '<img src="../../img/jiaoyan1.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="getVerify(\''+data.shipidnumber+'\')" title="点击查看详情">'; 
//	else if(data.verifyresult == 0)
//		str = '<img src="../../img/jiaoyan2.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="getVerify(\''+data.shipidnumber+'\')" title="点击查看详情">'; 
//	else if(data.verifyresult == -1)
//		str = '<img src="../../img/jiaoyan3.png" alt="" style="width:20px;height:20px;" data-toggle="modal" data-target="#modalCheck" onclick="getVerify(\''+data.shipidnumber+'\')" title="点击查看详情">'; 
	
	var htmlStr = ''+		
				'<tr id="tr_'+ data.shipidnumber +'">'+
				'	<td>'+ data.shipname +'</td>'+
				'	<td>'+ data.shipnameen +'</td>'+
				'	<td>'+ data.imo +'</td>'+
				'	<td>'+ data.portcode +'</td>'+
				'	<td>'+ data.grosstonnage +'</td>'+
				'	<td>'+ data.enginepower +'</td>'+
				'	<td>'+ data.typecode +'</td>'+
				'	<td>'+
				'		<input type="hidden" name="ship" id="ship'+data.shipidnumber+'" value=\''+ JSON.stringify(data) +'\'>'+
				'		<button onclick="deleteShip(\''+data.shipidnumber+'\');" type="button" class="btn btn-danger btn-sm" style="margin-right: 10px;">'+
				'			<span class="glyphicon glyphicon-minus"></span>'+
				'		</button>'+
				'	</td>'+
				'</tr>';

	$('#TableShip').append(htmlStr);
}